import { Injectable } from '@angular/core';
import { HttpClient } from '../../../../providers/httpClient';
import { Config } from '../../../../providers/config';
import _ from 'lodash';

@Injectable()
export class MarketingDailySaveService {
	constructor(
		public httpClient: HttpClient,
		public config: Config,
	) { }

	saveData(params) {
    let postBody = {
      "module": "KSB",
      "method": "USP_A03_0020",
      "type":"USP",
      "params": params
    };
    console.log(postBody);
    return this.httpClient.post(postBody);
  }

  getContackType() {
    let postBody = {
      "module": "KSB",
      "method": "USP_A02_0020",
      "type":"USP",
      "params": {
        "dicttype":"CONTRACTTYPE",
        "usr_id":""
      }
    };

    return this.httpClient.post(postBody, {
      isShowLoading: false
    });
  }

  /**
   * 获取机构联系人
   * @param agencycusid 机构客户ID
   * @returns {any}
   */
  getOrganizationContacts(agencycusid: string): any {
      let postBody = {
          module: "KSB",
          method: "USP_A02_0060",
          type: "USP",
          format: "json",
          params: {
              "agencycusid": agencycusid
          }
      };
      return this.httpClient.post(postBody, {
          isShowLoading: false
      });
  }

  getAgencyContacts(channelcusid) {
    let postBody = {
      "module": "KSB",
      "method": "USP_A02_0050",
      "type":"USP",
      "params": {
        "channelcusid": channelcusid
      }
    };

    return this.httpClient.post(postBody, {
      isShowLoading: false
    });
  }

  getUsrIDByLoginNM(login_nm) {
    let postBody = {
      "module": "KSB",
      "method": "USP_A02_0070",
      "type":"USP",
      "params": {
        "login_nm":login_nm
      }
    };

    return this.httpClient.post(postBody, {
      isShowLoading: false
    });
  }

  getUsrIDFromOAServer(login_nm) {
    let postBody = {
      "module": "OAServer",
      "method": "getUSBUsrIDByLoginID",
      "params": {
        "login_nm":login_nm
      }
    };

    return this.httpClient.post(postBody, {
      isShowLoading: false
    });
  }

}
